<template>
  <el-menu>
    <template v-for="item in list">
      <el-menu-item :key="item.path">
        <template slot="title">
          <i :class="item.icon"></i>
          <router-link :to="item.path">{{ item.text }}</router-link>
        </template>
      </el-menu-item>
    </template>
  </el-menu>
</template>

<script>
import axios from '@/utils/request'
export default {
  data() {
    return {
      list: [
        {
          path: '/layout/home',
          text: '首页',
          icon: 'el-icon-message',
        },
      ],
    }
  },
  created() {
    this.getMenusList()
  },
  methods: {
    async getMenusList() {
      const res = await axios.get('/api/rbac')
      console.log('用户身份路由', res.data)
      this.list = res.data
    },
  },
}
</script>

<style lang="scss" scoped>
.el-menu-item {
  position: relative;
  a {
    position: absolute;
    padding-left: 45px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
  }
}
</style>
